package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;

public class Input {
    BufferedReader bufferedReader;

    public Input(BufferedReader bufferedReader)
    {
        this.bufferedReader = bufferedReader;
    }


    public int getUserInput() {
        int index;

        try {
            index = Integer.parseInt(bufferedReader.readLine());
        } catch (NumberFormatException e) {
            index = -1;  //To change body of catch statement use File | Settings | File Templates.
        }
        catch(IOException e)
        {
            index = -1;
        }

        return index;
    }

    public String getUserNumber() {
        String userNumber;

        try {
            userNumber = bufferedReader.readLine();
        }
        catch (IOException e){
            return "Input Error";
        }
        return userNumber;
    }

    public String getUserPassword() {
        String password;

        try{
            password = bufferedReader.readLine();
        }
        catch (IOException e){
            return "Input Error";
        }

        return password;
    }
}
